package com.zxy.personage.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.zxy.personage.entity.SubscribeEntity;
import com.zxy.personage.service.SubscribeService;
import com.zxy.common.utils.PageUtils;
import com.zxy.common.utils.R;



/**
 * 房源预约表
 *
 * @author axy
 * @email sunlightcs@gmail.com
 * @date 2022-04-23 16:51:24
 */
@RestController
@RequestMapping("personage/subscribe")
@CrossOrigin
public class SubscribeController {
    @Autowired
    private SubscribeService subscribeService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = subscribeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{yid}")

    public R info(@PathVariable("yid") Integer yid){
		SubscribeEntity subscribe = subscribeService.getId(yid);

        return R.ok().put("subscribe", subscribe);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public R save(@RequestBody SubscribeEntity subscribe){
		subscribeService.save(subscribe);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SubscribeEntity subscribe){
		subscribeService.updateById(subscribe);

        return R.ok();
    }

    /**
     * 批删
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] yids){
		subscribeService.removeByIds(Arrays.asList(yids));

        return R.ok();
    }
    //删除
    @RequestMapping("/delete/{id}")
    public R delete(@PathVariable("id")Integer id){
        subscribeService.removeById(id);

        return R.ok();
    }

}
